package devc;

import java_cup.runtime.*;
import java.util.HashSet;
%%
%class Lex
%cup
%{
	public Lex(java.io.InputStream r, SymbolFactory sf){
		this(r);
		this.sf=sf;
	}
	private SymbolFactory sf;
	
	//public HashSet<String> varlist = new HashSet<String>();
%}
%eofval{
    return sf.newSymbol("EOF",sym.EOF);
%eofval}

IDENT =	[a-zA-Z][a-zA-Z0-9_]*
INT = 	[0-9]+
MASK  =   [01.]
SPACE =  [ \t\n\r]*

%%

{INT}     {return sf.newSymbol("",sym.T_INT,yytext());}
"("	{return sf.newSymbol("",sym.T_OPEN_PAR);}
")"	{return sf.newSymbol("",sym.T_CLOSE_PAR);}
";"	{return sf.newSymbol("",sym.T_PONTVIRG);}
":"	{return sf.newSymbol("",sym.T_DOISPONTOS);}
"DEVC"	{return sf.newSymbol("",sym.T_DEVC);}
"{"	{return sf.newSymbol("",sym.T_OPEN_CHAVE);}
"}"	{return sf.newSymbol("",sym.T_CLOSE_CHAVE);}
"="	{return sf.newSymbol("",sym.T_IGUAL);}
"\""	{return sf.newSymbol("",sym.T_ASPAS);}
"'"	{return sf.newSymbol("",sym.T_ASPA);}
"%"	{return sf.newSymbol("",sym.T_PERCENT);}
"%RESERVED"	{return sf.newSymbol("",sym.T_PERCENT_RESERVED);}
"%MASK"	{return sf.newSymbol("",sym.T_PERCENT_MASK);}
"s"	{return sf.newSymbol("",sym.T_S);}
"r"	{return sf.newSymbol("",sym.T_R);}
"."	{return sf.newSymbol("",sym.T_DOT);}
{MASK}{8}       {return sf.newSymbol("",sym.T_MASKREP,yytext());}
"dc_scml_port"	{return sf.newSymbol("",sym.T_DC_SCML_PORT);}
"dc_tlm_port"	{return sf.newSymbol("",sym.T_DC_TLM_PORT);}
"dc_clk_port"	{return sf.newSymbol("",sym.T_DC_CLK_PORT);}
"dc_format"	{return sf.newSymbol("",sym.T_DC_FORMAT);}
"dc_service"	{return sf.newSymbol("",sym.T_DC_SERVICE);}
">"	{return sf.newSymbol("",sym.T_MAIOR,">");}
"<"	{return sf.newSymbol("",sym.T_MENOR,"<");}
","	{return sf.newSymbol("",sym.T_VIRG);}
"READ"	{return sf.newSymbol("",sym.T_READ);}
"WRITE"	{return sf.newSymbol("",sym.T_WRITE);}
"dc_reg"	{return sf.newSymbol("",sym.T_DC_REG);}
"dc_buffer"	{return sf.newSymbol("",sym.T_DC_BUFFER);}
"dc_drv_map"	{return sf.newSymbol("",sym.T_DC_DRV_MAP);}
"dc_os"	{return sf.newSymbol("",sym.T_DC_OS);}
"dc_os_map"	{return sf.newSymbol("",sym.T_DC_OS_MAP);}
"OPEN"	{return sf.newSymbol("",sym.T_OPEN);}
"INIT"	{return sf.newSymbol("",sym.T_INIT);}
"RELEASE"	{return sf.newSymbol("",sym.T_RELEASE);}
"CLOSE"	{return sf.newSymbol("",sym.T_CLOSE);}
"IOCTL"	{return sf.newSymbol("",sym.T_IOCTL);}
"SEEK"	{return sf.newSymbol("",sym.T_SEEK);}
"DEV_CTOR"	{return sf.newSymbol("",sym.T_DEV_CTOR);}
"set_address"	{return sf.newSymbol("",sym.T_SET_ADDRESS);}
"bindTo"	{return sf.newSymbol("",sym.T_BINDTO);}
"set_actions"	{return sf.newSymbol("",sym.T_SET_ACTION);}
"pre"	{return sf.newSymbol("",sym.T_PRE,"pre");}
"pos"	{return sf.newSymbol("",sym.T_POS,"pos");}
"wait_state"	{return sf.newSymbol("",sym.T_WAIT_STATE);}
"interrupt"	{return sf.newSymbol("",sym.T_INTERRUPT);}
"polling"	{return sf.newSymbol("",sym.T_POLLING);}
"=="    {return sf.newSymbol("",sym.T_OPER,"==");}
"!="    {return sf.newSymbol("",sym.T_OPER,"!=");}
"<="    {return sf.newSymbol("",sym.T_OPER,"<=");}
">="	{return sf.newSymbol("",sym.T_OPER,">=");}
"+"	{return sf.newSymbol("",sym.T_PLUS);}
"uclinux"	{return sf.newSymbol("",sym.T_UCLINUX);}
{IDENT}     {return sf.newSymbol("Ident",sym.T_IDENT,yytext());}
{SPACE}     {            }
.           {            }
